#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;

const int kMaxN = 2e5 + 10;

int b[kMaxN];
int cnt[kMaxN];
queue<int> que[kMaxN];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int T;
  for (cin >> T; T; T--) {
    int n;
    cin >> n;

    fill(cnt, cnt + n + 1, 0);
    for (int i = 1; i <= n; i++) {
      cin >> b[i];
      cnt[b[i]]++;
    }

    int flag = 1;
    for (int i = 1; i <= n; i++) {
      if (cnt[i] % i != 0) {
        flag = -1;
        break;
      }
      que[i] = queue<int>();
      for (int j = 0; j < cnt[i] / i; j++, flag++) {
        for (int k = 0; k < i; k++) {
          que[i].push(flag);
        }
      }
    }
    if (flag == -1) {
      cout << "-1\n";
      continue;
    }
    for (int i = 1; i <= n; i++) {
      cout << que[b[i]].front() << " ";
      que[b[i]].pop();
    }
    cout << "\n";
  }
  return 0;
}